package net.hn.hnms.biz.project.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.project.request.ProblemRectificationReq;
import net.hn.hnms.biz.project.service.IProblemRectificationService;
import net.hn.hnms.biz.project.vo.ProblemRectificationVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 刘昊
 * @date 2024-03-13 10:19
 */
@Api(value = "问题整改单", tags = {"质量管理"})
@RestController
@RequestMapping("/qualityManagement/problemRectification")
public class ProblemRectificationController {

    @Autowired
    private IProblemRectificationService rectificationService;

    @ApiOperation("新增问题整改")
    @PostMapping("/add")
    @Log(title = "新增问题整改", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody ProblemRectificationReq req) {
        return rectificationService.insertReq(req);
    }

    @ApiOperation("删除问题整改")
//    @SaCheckPermission("problem:rectification:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除问题整改", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        return rectificationService.deleteList(idList);
    }

    @ApiOperation("修改问题整改")
//    @SaCheckPermission("problem:rectification:update")
    @PostMapping("/update")
    @Log(title = "修改问题整改", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody ProblemRectificationReq req) {
        return rectificationService.updateReq(req);
    }

    @ApiOperation("查询问题整改")
//    @SaCheckPermission("problem:rectification:select")
    @PostMapping("/selectPageList")
    @AutoSetMineCode
    @Log(title = "查询问题整改", businessType = BusinessType.UPDATE)
    public R<ResponsePage<List<ProblemRectificationVo>>> selectPageList(@Validated @RequestBody ProblemRectificationReq req, PageQuery pageQuery) {
        return rectificationService.selectPageList(req,pageQuery);
    }

}
